const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.jsx',
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'index.js',
    clean: true,
  },
  // watch: true,
  devtool: 'inline-source-map',
  resolve: {
    extensions: ['.jsx', '.js'],
  },
  module: {
    rules: [
      {
        test: /\.less$/i,
        use: [
          'style-loader',
          'css-loader',
          'less-loader'
        ]
      },
      {
        test: /\.css$/i,
        use: [
          'style-loader', 'css-loader',
        ]
      },
      {
        test: /\.svg$/,
        use: {
          loader: 'svg-loader'
        }
      },
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              '@babel/preset-react', 
              [
                '@babel/preset-env',
                {
                  useBuiltIns: "entry",
                  targets: {
                    // esmodules: true
                   
                    chrome: "58",
                    ie: "10"
                  },
                }
              ]
            ],
            plugins: [
              ["@babel/plugin-transform-runtime"],
              [
                "@babel/plugin-transform-regenerator",
                {
                  "asyncGenerators": true,
                  "generators": true,
                  "async": true
                }
              ],
              [
                "@babel/plugin-transform-destructuring", 
                { 
                  "useBuiltIns": true 
                }
              ] 
            ]
          }
        }
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Amy & Ahkari'
    }),
  ]
}